home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 October
/
EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso
/
Aminet
/
dev
/
gui
/
BGUI11c.lha
/
demos
/
window.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-19
|
6KB
|
159 lines
;/* Execute me to compile with DICE V3.0
dcc window.c -proto -mi -ms -mRR -lbgui
quit
*/
/*
** $RCSfile: window.c,v $
** Description: Simple demonstration of handling IDCMP
** events with the BGUI window class.
** Copyright: (C) Copyright 1994 Jaba Development.
** (C) Copyright 1994 Jan van den Baard.
** All Rights Reserved.
**
** $Author: jaba $
** $Revision: 1.2 $
** $Date: 1994/08/03 11:42:08 $
**/
#include <libraries/bgui.h>
#include <libraries/bgui_macros.h>
#include <libraries/gadtools.h>
#include <clib/alib_protos.h>
#include <proto/exec.h>
#include <proto/bgui.h>
#include <proto/intuition.h>
#include <stdio.h>
#include <stdlib.h>
/*
** Library base pointer.
** NOTE: The intuition.library is opened by DICE
** it's auto-init code.
**/
struct Library *BGUIBase;
/*
** Object ID's.
**/
#define ID_QUIT 1
int main( int argc, char *argv[] )
{
struct Window *window;
Object *WO_Window, *GO_Quit, *GO_Status;
ULONG signal = 0, rc, tmp = 0;
BOOL running = TRUE;
/*
** Open the library.
**/
if ( BGUIBase = OpenLibrary( BGUINAME, BGUIVERSION )) {
/*
** Create the window object.
**/
WO_Window = WindowObject,
WINDOW_Title, "Window Demo",
WINDOW_SizeGadget, FALSE,
WINDOW_MasterGroup,
VGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ),
StartMember, GO_Status = InfoFixed( NULL, ISEQ_C "Window Demo\n(C) Copyright 1993-1994 Jaba Development", NULL, 2 ), EndMember,
StartMember,
HGroupObject,
VarSpace( 50 ),
StartMember, GO_Quit = KeyButton( "_Quit", ID_QUIT ), EndMember,
VarSpace( 50 ),
EndObject,
EndMember,
EndObject,
EndObject;
/*
** Object created OK?
**/
if ( WO_Window ) {
/*
** Assign a key to the button.
**/
tmp = GadgetKey( WO_Window, GO_Quit, "q" );
/*
** OK?
**/
if ( tmp ) {
/*
** try to open the window.
**/
if ( window = WindowOpen( WO_Window )) {
/*
** Obtain it's wait mask.
**/
GetAttr( WINDOW_SigMask, WO_Window, &signal );
/*
** Event loop...
**/
do {
Wait( signal );
/*
** Handle events.
**/
while (( rc = HandleEvent( WO_Window )) != WMHI_NOMORE ) {
/*
** Evaluate return code.
**/
switch ( rc ) {
case WMHI_CLOSEWINDOW:
case ID_QUIT:
running = FALSE;
break;
case WMHI_INACTIVE:
SetAttrs( WO_Window, WINDOW_Title, "Window de-activated", TAG_END );
break;
case WMHI_ACTIVE:
SetAttrs( WO_Window, WINDOW_Title, "Window activated", TAG_END );
break;
}
}
} while ( running );
} else
puts ( "Could not open the window" );
} else
puts( "Could not assign gadget keys" );
/*
** Disposing of the window object will
** also close the window if it is
** already opened and it will dispose of
** all objects attached to it.
**/
DisposeObject( WO_Window );
} else
puts( "Could not create the window object" );
CloseLibrary( BGUIBase );
} else
puts( "Unable to open the bgui.library" );
return( 0 );
}
#ifdef _DCC
int wbmain( struct WBStartup *wbs )
{
return( main( 0, NULL ));
}
#endif
/*
* $Log: window.c,v $
* Revision 1.2 1994/08/03 11:42:08 jaba
* Switched from clib/ to proto/.
*
* Revision 1.1 1994/06/20 16:43:03 jaba
* Initial revision
*
*/